<template>
	<div class="home">
		<home-header></home-header>
		<home-swiper 
			:list="swiperList"
		></home-swiper>
		<home-icon
			:list="iconList"
		></home-icon>
		<home-footer></home-footer>

	</div>
</template>

<script>
	import HomeHeader from './components/HomeHeader'
	import HomeFooter from './components/HomeFooter'
	import HomeSwiper from  './components/homeSwiper'
	import HomeIcon from './components/HomeIcon'
	export default {
		name:'Home',
		data() {
			return {
				swiperList:[],
				iconList:[],
				recommendList:[],
				weekendList:[]
			}
		},
		components: {
			HomeHeader,
			HomeFooter,
			HomeSwiper,
			HomeIcon
		},
		methods: {
			getSwiperInfo() {
				this.axios.get('/api/index.json')
					.then( (res) => {
						res=res.data;
						if(res.code="200"){
							/*服务器返回值为真（res.ret为true）且res.data有数据*/
							if(res.ret && res.data){
								const data=res.data;
								this.swiperList=data.swiperList;
								this.iconList=data.iconList;
								this.recommendList=data.recommendList;
								this.weekendList=data.weekendList;
								console.log(this.swiperList)
							}
						}else {
							alert(res.code)
						}
					})
			}
		},
		/*页面初次加载，被挂载时*/
		mounted() {
			/*页面挂载完成后获取ajax请求*/
			this.getSwiperInfo()
		}
	};
</script>

<style lang="scss" scoped>

</style>